//社保基数管理 处理窗体
Ext.define("SHApp.CompanyManage.SocialInsurance.Form", {
    extend: "BLBTSystem.Form",
    submitUrl: "api/socialinsurance?format=json",
    requires: ['SHApp.EmployeeInfo.BasicInfo.CompanyComboBox'],
    winWidth: 665,
    winHeight: 235,
    txtCompanyNameID: "_txtCompanyNameID",
    txtPersonalBaseID: "_txtPersonalBaseID",
    initComponent: function () {
        Ext.apply(this);
        this.txtCompanyNameID += this.id;
        this.txtPersonalBaseID += this.id;
        this.createItems();
        this.callParent(arguments);
    },
    createItems: function () {
        var me = this;
        this.items = [{
            width: 300,
            border: false,
            bodyStyle: "background:#DFE9F6",
            layout: { type: "vbox", align: "stretch" },
            items: [{
                xtype: "textfield",
                fieldLabel: "ID",
                name: "Id",
                hidden: true
            }, {
                fieldLabel: "<span style='color:red'>*</span>公司名称",
                allowBlank: false,
                blankText: "请选择公司名称!",
                xtype: "companyComboBox",
                name: "CompanyId",
                maxLength: 50,
                listeners: {
                    select: function (c, r, o) {
                        if (r != null && r.length > 0) {
                            me.down("#" + me.txtCompanyNameID).setValue(this.getDisplayValue());
                        }
                    }
                }
            }, {
                fieldLabel: "<span style='color:red'>*</span>社保名称",
                allowBlank: false,
                blankText: "请输入社保名称!",
                xtype: "textfield",
                name: "Name",
                maxLength: 50
            }, {
                fieldLabel: "<span style='color:red'>*</span>企业比例",
                allowBlank: false,
                blankText: "请输入企业比例!",
                xtype: "numberfield",
                name: "CompanyRatio",
                maxLength: 9,
                enforceMaxLength: true,
                minValue: 0
            }, {
                fieldLabel: "<span style='color:red'>*</span>企业基数",
                allowBlank: false,
                blankText: "请输入企业基数!",
                xtype: "numberfield",
                name: "CompanyBase",
                maxLength: 9,
                enforceMaxLength: true,
                minValue: 0
            }, {
                fieldLabel: "企业附加金额",
                xtype: "numberfield",
                name: "CompanyPlus",
                maxLength: 9,
                enforceMaxLength: true,
                minValue: 0
            }]
        }, {
            width: 300,
            border: false,
            bodyStyle: "background:#DFE9F6",
            layout: { type: "vbox", align: "stretch" },
            items: [{
                fieldLabel: "<span style='color:red'>*</span>公司名称",
                allowBlank: false,
                blankText: "请输入公司名称!",
                xtype: "textfield",
                name: "CompanyName",
                maxLength: 50,
                id: me.txtCompanyNameID,
                hidden: true
            }, {
                fieldLabel: "<span style='color:red'>*</span>个人比例",
                allowBlank: false,
                blankText: "请输入个人比例!",
                xtype: "numberfield",
                name: "PersonalRatio",
                maxLength: 9,
                enforceMaxLength: true,
                minValue: 0
            }, {
                xtype: "radiogroup",
                fieldLabel: "<span style='color:red'>*</span>是否固定",
                allowBlank: false,
                blankText: "请选择是否固定!",
                columns: 2,
                // vertical: true,
                items: [
                    { boxLabel: '是', name: 'IsFixed', inputValue: true },
                    { boxLabel: '否', name: 'IsFixed', inputValue: false, checked: true }
                ],
                listeners: {
                    change: function (field, newValue, oldValue, opt) {
                        if (newValue.IsFixed) {
                            me.down("#" + me.txtPersonalBaseID).setValue(0);
                            me.setReadOnly(me.txtPersonalBaseID, true);
                        } else {
                            me.setReadOnly(me.txtPersonalBaseID, false);
                        }
                    }
                }
            }, {
                fieldLabel: "<span style='color:red'>*</span>个人基数",
                allowBlank: false,
                blankText: "请输入个人基数!",
                xtype: "numberfield",
                name: "PersonalBase",
                maxLength: 9,
                enforceMaxLength: true,
                minValue: 0,
                id: me.txtPersonalBaseID
            }, {
                fieldLabel: "个人附加金额",
                xtype: "numberfield",
                name: "PersonalPlus",
                maxLength: 9,
                enforceMaxLength: true,
                minValue: 0
            }]
        }
		];
    },
    setReadOnly: function (id, bl) {
        var me = this;
        me.down("#" + id).setReadOnly(bl);
    }
})